/*
 * @(#) PublicEvaAction.java 2011-9-28
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.publiceva.presentation.action;

import java.util.ArrayList;
import java.util.List;

import cn.strong.gweva.common.business.entity.ComboBoxEntity;
import cn.strong.gweva.common.presentation.action.AjaxBaseAction;
import cn.strong.gweva.common.util.ComboBoxUtil;
import cn.strong.gweva.publiceva.business.entity.PublicEvaEntity;
import cn.strong.gweva.publiceva.business.service.PublicEvaService;

/**
 * 公共考核Action。
 * 
 * @author lilanfei
 * @version 1.0
 * @since 2011-9-28
 */
public class PublicEvaAction extends AjaxBaseAction
{
	/**  */
	private static final long serialVersionUID = 1557171563641694589L;
	/** 公共考核接口 */
	private PublicEvaService publicEvaService;

	/** 公共考核项目下拉列表 */
	private List<ComboBoxEntity> itemList;
	/** 公共考核规则下拉列表 */
	private List<ComboBoxEntity> ruleList;
	/** 公共考核entity */
	private PublicEvaEntity publicEvaEntity;

	/**
	 * 新增公共考核初始化.
	 * 
	 * @return
	 */
	public String add()
	{
		try
		{
			this.setItemList(ComboBoxUtil.searchPublicItemList());
			if (this.getPublicEvaEntity() == null)
			{
				this.setPublicEvaEntity(new PublicEvaEntity());
			}
			this.setRuleList(ComboBoxUtil.searchPublicRuleList(this.getPublicEvaEntity().getItemId()));
		}
		catch (Exception e)
		{
			return processException(e);
		}
		return ADD;
	}

	/**
	 * 新增公共考核.
	 * 
	 * @return
	 */
	public String insert()
	{
		try
		{
			this.getPublicEvaEntity().setUpdateUserId(this.getLoginUser().getUserId());
			this.getPublicEvaService().insertPublicEva(this.getPublicEvaEntity());
			this.setPublicEvaEntity(new PublicEvaEntity());
			this.setIsSuccess("保存成功！");
		}
		catch (Exception e)
		{
			return processException(e);
		}

		return this.add();
	}

	/**
	 * 获取公共考核接口
	 * @return 公共考核接口
	 */
	public PublicEvaService getPublicEvaService()
	{
		return publicEvaService;
	}
	/**
	 * 设定公共考核接口
	 * @param publicEvaService 公共考核接口
	 */
	public void setPublicEvaService(PublicEvaService publicEvaService)
	{
		this.publicEvaService = publicEvaService;
	}

	/**
	 * 获取公共考核项目下拉列表
	 * @return 公共考核项目下拉列表
	 */
	public List<ComboBoxEntity> getItemList()
	{
		if (itemList == null)
		{
			itemList = new ArrayList<ComboBoxEntity>();
		}
		return itemList;
	}
	/**
	 * 设定公共考核项目下拉列表
	 * @param itemList 公共考核项目下拉列表
	 */
	public void setItemList(List<ComboBoxEntity> itemList)
	{
		this.itemList = itemList;
	}

	/**
	 * 获取公共考核规则下拉列表
	 * @return 公共考核规则下拉列表
	 */
	public List<ComboBoxEntity> getRuleList()
	{
		if (ruleList == null)
		{
			ruleList = new ArrayList<ComboBoxEntity>();
		}
		return ruleList;
	}
	/**
	 * 设定公共考核规则下拉列表
	 * @param ruleList 公共考核规则下拉列表
	 */
	public void setRuleList(List<ComboBoxEntity> ruleList)
	{
		this.ruleList = ruleList;
	}

	/**
	 * 获取公共考核entity
	 * @return 公共考核entity
	 */
	public PublicEvaEntity getPublicEvaEntity()
	{
		return publicEvaEntity;
	}
	/**
	 * 设定公共考核entity
	 * @param publicEvaEntity 公共考核entity
	 */
	public void setPublicEvaEntity(PublicEvaEntity publicEvaEntity)
	{
		this.publicEvaEntity = publicEvaEntity;
	}

}
